package com.sky.controller.admin;

import com.sky.result.Result;
import com.sky.service.FileUploadService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.apache.ibatis.annotations.Param;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.multipart.MultipartFile;

import java.io.IOException;

@RestController
@RequestMapping("/admin/common")
@Api(tags = "通用服务相关接口")
public class FileUploadController {

    @Autowired
    private FileUploadService fileUploadService;

    @PostMapping("/upload")
    @ApiOperation("上传图片")
    public Result<String> upload(@Param("file") MultipartFile file) throws IOException {
        String imgUrl = fileUploadService.upload(file);
        return Result.success(imgUrl);
    }
}
